#include "stdafx.h"
#include "DBSDBWrap.h"
#include "DBSDefaultConnect.h"

namespace dbsdb{

CDBSDBWrap::CDBSDBWrap(dydb::CCDDatabase* pDatebase)
{
	m_pDatebase= NULL;

	if (pDatebase != NULL)
	{
		m_pDatebase= pDatebase;
	}else
	{
		m_pDatebase= &CDBSDefaultConnect::Instance();
	}
}

void CDBSDBWrap::SetDataBase(dydb::CCDDatabase* pDatebase)
{
	if (pDatebase != NULL)
	{
		m_pDatebase= pDatebase;
	}else
	{
		m_pDatebase= &CDBSDefaultConnect::Instance();
	}
}

CDBSDBWrap::~CDBSDBWrap(void)
{
}

BOOL CDBSDBWrap::DbReConnect()
{
	if (m_pDatebase == NULL)
		return FALSE;

	return m_pDatebase->Open();
}

BOOL CDBSDBWrap::BeginTrans()
{
	if (m_pDatebase == NULL)
		return FALSE;

	return m_pDatebase->BeginTrans();
}
BOOL CDBSDBWrap::BeginTrans(dydb::CCDDatabase* pDB)
{
	if (pDB == NULL)
		return FALSE;

	return pDB->BeginTrans();
}
BOOL CDBSDBWrap::CommitTrans()
{
	if (m_pDatebase == NULL)
		return FALSE;

	return m_pDatebase->CommitTrans();
}
BOOL CDBSDBWrap::CommitTrans(dydb::CCDDatabase* pDB)
{
	if (pDB == NULL)
		return FALSE;

	return pDB->CommitTrans();
}
BOOL CDBSDBWrap::RollbackTrans()
{
	if (m_pDatebase == NULL)
		return FALSE;

	return m_pDatebase->RollbackTrans();
}
BOOL CDBSDBWrap::RollbackTrans(dydb::CCDDatabase* pDB)
{
	if (pDB == NULL)
		return FALSE;

	return pDB->RollbackTrans();
}
BOOL CDBSDBWrap::ExecuteSQL(LPCTSTR szSQL)
{
	if (m_pDatebase == NULL)
		return FALSE;

	return m_pDatebase->ExecuteSQL(szSQL);
};


};using namespace dbsdb;